package com.sjz.han.industry.base;


import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;


import java.util.LinkedList;
import java.util.List;


/**
 * desc: .
 * author: Will .
 * date: 2017/9/2 .
 */
public class MyApp extends Application {


    public static MyApp myAppContext;

    public static int width = 0;

    public static int height = 0;

    private static List<Activity> activityList = new LinkedList<Activity>();
    @Override
    public void onCreate() {
        super.onCreate();
        myAppContext = this;
    }
    public static MyApp getInstance() {
        return myAppContext;
    }
    public static MyApp myApp=null;
    //单例application
    public static MyApp getMyApp(){
        if(myApp==null){
            myApp= new MyApp();
        }
        return myApp;
    }

    public void addActivity(Activity activity)  {
        activityList.add(activity);
    }
    public void removeActivity(Activity activity){
        activityList.remove(activity);
    }
    public void exitAllActivity(){
        for(Activity activity:activityList) {
            activity.finish();
        }
    }
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
